﻿{template header}

    {template sidebar}

    <!-- artile begin -->
    <div class="article">

        {template title}
    <!--{if $a == 'index'}-->
        <form class="form-search" action="{$this->url($c, null, $this->get())}">
            <table>
                <tr><td class="td1" width="20%">供货商名称：</td>
                    <td>

                        <div class="input-append">
                            <input type="text" name="key" class="span2 search-query" placeholder="请输入商品名称" />
                            <button type="button" class="btn search">搜索</button>
                        </div>
                    </td >
            </table>
            </tr>
        </form>


        <table>
            <tr>
                <th width="5%"><input type="checkbox" class="all" /></th>
                <th width="15%">编号</th>
                <th width="20%">名称</th>
                <th width="15%">类型</th>
                <th width="15%">地址</th>
                <th width="15%">操作</th>
            </tr>
        <!--{if $result}-->
            <!--{loop $result $v}-->
            <tr>
                <td><input type="checkbox" name="id" value="{$v['id']}" /></td>
                <td>{$v['supplierNo']}</td>
                <td>{$v['name']}</td>
                <td>{$v['type']}</td>
                <td>{$v['address']}</td>
                <td class="operate">
                    <a href="{$this->url($c,'edit',array('id'=>$v['id']))}">编辑</a>
                    <a title="删除" class="del" href="{$this->url($c,'del',array('id'=>$v['id']))}">删除</a>
                </td>
            </tr>
            <!--{/loop}-->
        <!--{else}-->
            <tr>
                <td colspan="6">没有记录!</td>
            </tr>
        <!--{/if}-->

        <!--{if $pager}-->
            <!--分页开始-->
            <tr>
                <td colspan="6">
                    <div class="page">{$pager}</div>
                </td>
            </tr>
            <!--分页结束-->
        <!--{/if}-->
            <tr>
                <td colspan="4" class="td4">
                    <a title="添加供货商" class="btn btn-success " href="{$this->url($c,'add',$result['id'])}">添加供货商</a>
                </td>
            </tr>
        </table>

    <!--{/if}-->
    <!--{if  $a == 'add' || $a == 'edit'}-->
        <form method="post" action="{$this->url($c, 'save', array('id' => $result['id']))}">
        <table>
            <tr>
                <td class="td1" width="25%">商家编号：</td>
                <td class="td2 operate">
                    <input type="text" name="supplierNo" placeholder="请输入供货商编号" class="required" value="{$a == 'edit' ? $result['supplierNo'] : ''}" />
                    <a format="YmdHis" title="保存供货商" class="supplierNo" href="{$this->url($c)}">自动生成</a>
                    <a href="{$this->url('contact','add', array('supplierName' => $result['name']))}">添加联系人</a>
                    <a href="{$this->url('contact', null, array('key' => $result['name']))}">联系人查询</a>
                </td>
            </tr>
            <tr>
                <td class="td1">商家名称：</td>
                <td class="td2">
                    <input type="text" name="name" placeholder="请输入供货商名称" class="required" value="{$a == 'edit' ? $result['name'] : ''}" />
                </td>
            </tr>

            <tr>
                <td class="td1">商家地址：</td>
                <td class="td2">
                    <input type="text" name="address" class="input-xlarge" placeholder="请输入供货商地址" value="{$a == 'edit' ? $result['address'] : ''}" />
                </td>
            </tr>

            <tr>
                <td class="td1">商家类型：</td>
                <td class="td2">
                    <select name="type">
                    <!--{loop $this->supplierType $v}-->
                        <option value="{$v}"{$v == $result['type'] ? ' selected' : ''}>{$v}</option>
                    <!--{/loop}-->
                    </select>
                </td>
            </tr>

            <tr>
                <td class="td1">品质等级：</td>
                <td class="td2">
                    <select name="grade">
                    <!--{loop $this->supplieGrand $v}-->
                        <option value="{$v}"{$v == $result['grade'] ? ' selected' : ''}>{$v}</option>
                    <!--{/loop}-->
                    </select>
                  </td>
              </tr>

              <tr>
                  <td class="td1">经营品类：</td>
                  <td class="td2">
                      {eval $select = (stripos($result['businessType'],"1") !== false) ? 'checked' : ''}
                      <input type="checkbox" name="businessType[]" value="1"  {$select} />婴幼装
                      {eval $select = (stripos($result['businessType'],"2") !== false) ? 'checked' : ''}
                      <input type="checkbox" name="businessType[]" value="2"  {$select} />中小童
                      {eval $select = (stripos($result['businessType'],"3") !== false) ? 'checked' : ''}
                      <input type="checkbox" name="businessType[]" value="3"  {$select} />中大童
                </td>
            </tr>

            <tr>
                <td class="td1">折扣信息：</td>
                <td class="td2">
                    <select name="discount">
                    <!--{loop $this->supplieDiscount $v}-->
                        <option value="{$v}"{$v == $result['discount'] ? ' selected' : ''}>{$v}</option>
                    <!--{/loop}-->
                    </select>
                 </td>
             </tr>
            <tr>
                <td class="td1">收货地址：</td>
                <td class="td2">
                    <input type="text" class="input-xlarge" name="receiveAddress" placeholder="请输入收货地址" value="{$a == 'edit' ? $result['receiveAddress'] : ''}" />
                </td>
            </tr>
            <tr>
                <td class="td1">备注：</td>
                <td class="td2">
                    <textarea name="remark" placeholder="请输入备注" cols="50" rows="5"> {$a == 'edit' ? $result['remark'] : ''}</textarea>
                </td>
            </tr>
             <tr>
                 <th colspan="2" class="td4">
                     <a title="保存供货商" class="btn btn-success save" href="{$this->url($c)}">保 存</a>
                 </th>
             </tr>
         </table>
         </form>
        <script type="text/javascript">
            $( ".supplierNo" ).click( function () {
                var c = $( this ).attr( 'class' );
                $.get( "{$this->url($c, 'get_date')}&format=" + $( this ).attr( 'format' ), function ( result ) {
                    $( 'input[name="' + c + '"]' ).val( result );
                    $( 'input[name="' + c + '"]' ).focus();
                });
                return false;
            });
        </script>
    <!--{/if}-->
    </div>
<!-- artile end -->
{template footer}